package recallin.activities;

import java.io.IOException;
import java.util.zip.ZipException;

import recallin.database.ZipUtil;
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.TextView;

/**
 * A unused class that is meant to be used for the download of the application.
 * Unzips all content into a folder on the default mount point of th android
 * phone.
 * 
 * @author philipmasek
 * 
 */

public class StartActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		final Handler handler = new Handler() {
			@Override
			public void handleMessage(Message msg) {
				TextView t = new TextView(getApplicationContext());
				t.setText("DONE!!!!!");
				setContentView(t);
				super.handleMessage(msg);
			}
		};
		Thread thread = new Thread() {
			@Override
			public void run() {
				try {
					ZipUtil.extractFolder(ZipUtil.getDefaultFolderPath()
							+ "Streets.zip");
					ZipUtil.extractFolder(ZipUtil.getDefaultFolderPath()
							+ "POI.zip");
				} catch (ZipException e) {
					e.printStackTrace();
				} catch (IOException e) {
					e.printStackTrace();
				}
				handler.sendEmptyMessage(0);
				super.run();
			}
		};
		thread.start();
		super.onCreate(savedInstanceState);
		setContentView(R.layout.loading_view);
	}

}
